# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=monero
pkgver=0.18.2.2
_commit=e06129bb4d1076f4f2cebabddcee09f1e9e30dcc
pkgrel=1
pkgdesc="Monero: the secure, private, untraceable peer-to-peer currency"
license=('BSD')
arch=('loong64' 'x86_64')
url="https://getmonero.org/"
depends=('boost-libs' 'libunwind' 'openssl' 'readline' 'zeromq' 'pcsclite' 'hidapi' 'protobuf' 'libusb' 'libudev.so' 'libunbound.so')
makedepends=('boost' 'cmake' 'git' 'python')
source=(
    "${pkgname}"::"git+https://github.com/monero-project/monero?signed#commit=${_commit}"
    "git+https://github.com/monero-project/supercop.git"
    "git+https://github.com/miniupnp/miniupnp.git"
    "git+https://github.com/Tencent/rapidjson.git"
    "git+https://github.com/trezor/trezor-common.git"
    "git+https://github.com/tevador/randomx.git"
    "monero.sysusers"
    "monero.tmpfiles"
)
sha512sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            '2e4ecf3f305dab46e166f50c0451dd969927b485df544aebcf8115a65444573e6d57a8ac6bea64ce5ab4b5cce2c70f913d9ac3bce561c59acf89851edc76a22c'
            'ae3c300548e6ba5fdf6a203146e5dcaf1955c3e19820c0bb3a73bb70ec5629a3af00d43dac95b6f3832ded5c480e872d829981a63206016d4a64f3940b713357')
validpgpkeys=(
  '8777AB8F778EE89487A2F8E7F4ACA0183641E010' # luigi1111 <luigi1111w@gmail.com>
  'BDA6BD7042B721C467A9759D7455C5E3C0CDCEB9' # Riccardo Spagni <ric@spagni.net>
  '487277A8BD0A209C16B700F3C64552D877C32479' # Alexander Blair (Snipa / Snipa22) <snipa@jagtech.io>
)

prepare() {
  cd "${pkgname}"
  git submodule init
  git config submodule.external/supercop.url "$srcdir/supercop"
  git config submodule.external/miniupnp.url "$srcdir/miniupnp"
  git config submodule.external/rapidjson.url "$srcdir/rapidjson"
  git config submodule.external/trezor-common.url "$srcdir/trezor-common"
  git config submodule.external/randomx.url "$srcdir/randomx"
  git -c protocol.file.allow=always submodule update
}

build() {
  cd "${pkgname}"
  mkdir -p build && cd build
  cmake -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=release -D ARCH=default ../
  make
}

package() {
  backup=('etc/monerod.conf')

  cd "${pkgname}"
  install -Dm644 "LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"

  install -Dm644 "utils/conf/monerod.conf" "${pkgdir}/etc/monerod.conf"
  install -Dm644 "utils/systemd/monerod.service" "${pkgdir}/usr/lib/systemd/system/monerod.service"
  install -Dm644 "../monero.sysusers" "${pkgdir}/usr/lib/sysusers.d/monero.conf"
  install -Dm644 "../monero.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/monero.conf"

  install -Dm755 "build/bin/monero-blockchain-ancestry" \
                 "build/bin/monero-blockchain-depth" \
                 "build/bin/monero-blockchain-export" \
                 "build/bin/monero-blockchain-import" \
                 "build/bin/monero-blockchain-mark-spent-outputs" \
                 "build/bin/monero-blockchain-prune" \
                 "build/bin/monero-blockchain-prune-known-spent-data" \
                 "build/bin/monero-blockchain-stats" \
                 "build/bin/monero-blockchain-usage" \
                 "build/bin/monero-gen-ssl-cert" \
                 "build/bin/monero-gen-trusted-multisig" \
                 "build/bin/monero-wallet-cli" \
                 "build/bin/monero-wallet-rpc" \
                 "build/bin/monerod" \
                 -t "${pkgdir}/usr/bin"
}

# vim: ts=2 sw=2 et:
